let csvUtil = module.exports = {};
let parse = require('csv-parse');
let fs = require('fs');

csvUtil.parseCSV = async function (fileName) {
    return new Promise((resolve, reject) => {
        try {
            let parser = parse({delimiter: ','}, function (err, data) {
                if (err){
                    reject(err);
                } else {
                    resolve(data);
                }
            });
            fs.createReadStream(__dirname + "/" +fileName).pipe(parser);
        }catch (e) {
            reject(e);
        }
    });
};